# Copyright 2024-2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_cc//cc:cc_library.bzl", "cc_library")

package(
    default_visibility = ["//ink:__subpackages__"],
)

cc_library(
    name = "jni_defines",
    hdrs = ["jni_defines.h"],
)

cc_library(
    name = "jni_jvm_interface",
    srcs = ["jni_jvm_interface.cc"],
    hdrs = ["jni_jvm_interface.h"],
    deps = [
        ":jni_defines",
        "@com_google_absl//absl/log:absl_check",
    ] + select({
        "@platforms//os:android": [],
        "//conditions:default": [
            "@rules_jni//jni",
        ],
    }),
)

cc_library(
    name = "jni_string_util",
    srcs = ["jni_string_util.cc"],
    hdrs = ["jni_string_util.h"],
    deps = [
        "@com_google_absl//absl/log:absl_check",
        "@com_google_absl//absl/strings:string_view",
    ] + select({
        "@platforms//os:android": [],
        "//conditions:default": [
            "@rules_jni//jni",
        ],
    }),
)

cc_library(
    name = "jni_throw_util",
    srcs = ["jni_throw_util.cc"],
    hdrs = ["jni_throw_util.h"],
    deps = [
        ":jni_jvm_interface",
        ":jni_string_util",
        "@com_google_absl//absl/log:absl_check",
        "@com_google_absl//absl/status",
    ] + select({
        "@platforms//os:android": [],
        "//conditions:default": [
            "@rules_jni//jni",
        ],
    }),
)

cc_library(
    name = "jni_proto_util",
    srcs = ["jni_proto_util.cc"],
    hdrs = ["jni_proto_util.h"],
    deps = [
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/log:absl_check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@protobuf//:protobuf_lite",
    ] + select({
        "@platforms//os:android": [],
        "//conditions:default": [
            "@rules_jni//jni",
        ],
    }),
)
